<!DOCTYPE html>
<html>
{include file="public/header" /}
<style type="text/css">
	.diyinput {
		height: 38px;
		line-height: 1.3;
		line-height: 38px;
		border-width: 1px;
		border-style: solid;
		background-color: #fff;
		border-radius: 2px;
		border-color: #f1eeee;
	}
</style>

<body>
	<div class="layui-fluid">
		<div class="layui-card">
			<div class="layui-form layui-card-header layuiadmin-card-header-auto">
				<div class="layui-form-item">
					{include file="public/sorch" /}
					{include file="public/qudao" /}
					{include file="public/yyfkTime" /}

					<div class="layui-inline">
						<button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
							<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
						</button>
					</div>
				</div>
			</div>

			<div class="layui-card-body">

				<table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>
				<script type="text/html" id="imgTpl">
						<img style="display: inline-block; width: 50%; height: 100%;" src={ { d.avatar }}>
					</script>

				<script type="text/html" id="table-useradmin-webuser">
						<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="detail"><i class="layui-icon"></i>详情</a>
						
					</script>
			</div>
		</div>
	</div>

	{include file="public/footer" /}
	<script>
		layui.use(['index', 'table', 'laydate'], function () {
			var $ = layui.$,
				form = layui.form,
				table = layui.table,
				laydate = layui.laydate;

			laydate.render({
				elem: '#time1' //指定元素
			});
			laydate.render({
				elem: '#time2' //指定元素
			});
			table.render({
				elem: '#LAY-user-manage',
				even: true, //开启隔行背景
				url: "{:url('admin/orderhuankuan/get_list')}?songsong=yiwancheng",
				toolbar: '#test-table-toolbar-toolbarDemo',
				title: '用户数据表',
				height: 'full-300',//最大高度
				cols: [
					[{
						type: 'checkbox',
						fixed: 'left'
					},
					{
						type: 'numbers',
						title: '排序',
						width: 40,
						fixed: 'left',
						unresize: true,
					},
					{
						field: 'TrueName',
						title: '用户名',
						width: 80,
					},
					{
						field: 'Mobile',
						title: '手机号',
						width: 120,

					},
					{
						field: 'DaichaoName',
						title: '渠道',
						width: 80,

					},
					{
						type: 'hidden',
						field: 'ID',
						title: 'ID',
						width: 120
					},
					{
						field: 'cuishourenID',
						title: '催收人',
						width: 100,
					},
					
					{
						field: 'LoanStatus',
						title: '状态',
						width: 80,
					},


					//							{
					//								field: 'IDCard',
					//								title: '身份证号',
					//								width: 175,
					//
					//							},
					{
						field: 'jishen',
						title: '机审结果',
						width: 100,

					},
					{
						field: 'ApplyMoney',
						title: '订单金额',
						width: 100,
					},
					{
						field: 'ApplyDay',
						title: '期限',
						width: 60,
					},
					{
						field: 'AdoptMoney',
						title: '到账金额',
						width: 100,
					},

					{
						field: 'jianmian_money',

						title: "<span lay-tips='豁免金额'><p style='text-align:center'>应还减免？</p></span>",
						width: 100,
					},
					{
						field: 'shiji_money',
						title: "<span lay-tips='结清金额+部分还款/全额还款'><p style='text-align:center'>实际还款？</p></span>",
						width: 100,
					},

					{
						field: 'huankuan_typr',
						title: "<span lay-tips='正常还款/逾期还款'><p style='text-align:center'>还款类型？</p></span>",
						width: 100,
					},
					{
						field: 'fakuan_yiwancheng',
						title: '应还罚息',
						width: 100,
					},
					{
						field: 'datas__yiwancheng',
						title: "<span lay-tips='截止订单完成时间的逾期天数'><p style='text-align:center'>逾期天数？</p></span>",
						width: 100,
					},


					{
						field: 'daoqiMoney',
						title: '到期应还',
						width: 100,
					},

					{
						field: 'user_type',
						title: '客户类型',
						width: 100,
					},
					{
						field: 'OpenTime',
						title: '放款时间',
						width: 160,
					},
					{
						field: 'YyFkTime',
						title: '预约还款时间',
						width: 160,
					},
					{
						field: 'SjFkTime',
						title: '实际还款时间',
						width: 160,
					},
					{
						field: 'bufenhuankuan',
						title: '部分还款',
						width: 100,
					},

					{
						field: 'bufenhuankuan_num',
						title: '次数',
						width: 80,
					},

				
					{
						field: 'xjnums_status',
						title: '是否展期',
						width: 100,
					},


					{
						field: 'xjnums',
						title: '展期次数',
						width: 100,
					},
					{
						field: 'Jktime',
						title: '(总)借款次数',
						width: 120
					},
					{
						field: 'OrderSn',
						title: '订单编号',
						width: 180,
					},
					{
						fixed: 'right',
						title: '操作',
						toolbar: '#table-useradmin-webuser',
						width: 70
					}
					]

				],
				page: true,
				done: function () {
					$("[data-field='ID']").css('display', 'none');
				}
			});

			//监听工具条
			table.on('tool(LAY-user-manage)', function (obj) {
				var data = obj.data;
				if (obj.event === 'detail') {
					layer.open({
						type: 2,
						title: '用户详情',
						content: 'detail.html?ID=' + data.ID,
						area: ['90%', '90%'],
						btn: ['确定', '取消'],

					});

				} else if (obj.event === 'zhanqi') {
					layer.open({
						type: 2,
						title: '展期用户',
						content: 'zhanqi.html?ID=' + data.ID,
						area: ['50%', '80%'],
						btn: ['确定', '取消'],
						yes: function (index, layero) {
							var iframeWindow = window['layui-layer-iframe' + index],
								submitID = 'LAY-user-back-submit',
								submit = layero.find('iframe').contents().find('#' + submitID);
							//监听提交
							iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
								var field = data.field; //获取提交的字段
								//								
								//提交 Ajax 成功后，静态更新表格中的数据
								$.ajax({
									'type': 'post',
									'url': "{:url('admin/orderhuankuan/zhanqi_caozuo')}",
									'data': field,
									dataType: 'json',
									success: function (res) {
										if (res.code == '0') {
											layer.msg(res.msg, {
												icon: 1
											});
										} else {
											layer.msg(res.msg, {
												icon: 5
											});
										}
										table.reload('LAY-user-manage');
										layer.close(index); //关闭弹层
									}
								});

							});

							submit.trigger('click');
						}
					});
				} else if (obj.event === 'huankuan') {
					layer.open({
						type: 2,
						title: '线下还款',
						content: 'huankuan.html?ID=' + data.ID,
						area: ['50%', '80%'],
						btn: ['确定', '取消'],
						yes: function (index, layero) {
							var iframeWindow = window['layui-layer-iframe' + index],
								submitID = 'LAY-user-back-submit',
								submit = layero.find('iframe').contents().find('#' + submitID);
							//监听提交
							iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
								var field = data.field; //获取提交的字段
								//								
								//提交 Ajax 成功后，静态更新表格中的数据
								$.ajax({
									'type': 'post',
									'url': "{:url('admin/orderhuankuan/huankuan_caozuo')}",
									'data': field,
									dataType: 'json',
									success: function (res) {
										if (res.code == '0') {
											layer.msg(res.msg, {
												icon: 1
											});
										} else {
											layer.msg(res.msg, {
												icon: 5
											});
										}
										table.reload('LAY-user-manage');
										layer.close(index); //关闭弹层
									}
								});

							});

							submit.trigger('click');
						}
					});
				}
			});
			//监听搜索
			form.on('submit(LAY-user-front-search)', function (data) {
				var field = data.field;

				//执行重载
				table.reload('LAY-user-manage', {
					where: field
				});
			});

			//事件
			var active = {
				batchdel: function () {
					var checkStatus = table.checkStatus('LAY-user-manage'),
						checkData = checkStatus.data; //得到选中的数据

					if (checkData.length === 0) {
						return layer.msg('请选择数据');
					}

					layer.prompt({
						formType: 1,
						title: '敏感操作，请验证口令'
					}, function (value, index) {
						layer.close(index);

						layer.confirm('确定删除吗？', function (index) {

							//执行 Ajax 后重载
							/*
							admin.req({
								url: 'xxx'
								//,……
							});
							*/
							table.reload('LAY-user-manage');
							layer.msg('已删除');
						});
					});
				},
				add: function () {
					layer.open({
						type: 2,
						title: '添加用户',
						content: 'userform.html',
						maxmin: true,
						area: ['500px', '450px'],
						btn: ['确定', '取消'],
						yes: function (index, layero) {
							var iframeWindow = window['layui-layer-iframe' + index],
								submitID = 'LAY-user-front-submit',
								submit = layero.find('iframe').contents().find('#' + submitID);

							//监听提交
							iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
								var field = data.field; //获取提交的字段

								//提交 Ajax 成功后，静态更新表格中的数据
								//$.ajax({});
								table.reload('LAY-user-front-submit'); //数据刷新
								layer.close(index); //关闭弹层
							});

							submit.trigger('click');
						}
					});
				}
			};


			//				设置催收人员
			table.on('toolbar(LAY-user-manage)', function (obj) {
				var checkStatus = table.checkStatus(obj.config.id);
				switch (obj.event) {
					case 'getCheckData':
						var data = checkStatus.data;
						var idarr = data.map((item, index) => {
							return item.ID
						})
						var idarr = JSON.stringify(idarr);

						layer.open({
							type: 2,
							title: '分配催收专员',
							content: 'couishou_people_add.html',
							area: ['520px', '520px'],
							btn: ['确定', '取消'],
							yes: function (index, layero) {
								var iframeWindow = window['layui-layer-iframe' + index],
									submitID = 'LAY-user-back-submit',
									submit = layero.find('iframe').contents().find('#' + submitID);

								//监听提交
								iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
									var field = data.field; //获取提交的字段
									//提交 Ajax 成功后，静态更新表格中的数据
									$.ajax({
										'type': 'post',
										'url': "{:url('admin/orderyuqi/cuishou_people')}",
										'data': { 'idarr': idarr, 'cuishouren': field['cuishou'] },

										dataType: 'json',
										success: function (res) {
											if (res.code == '0') {
												layer.msg(res.msg, {
													icon: 1
												});
											} else {
												layer.msg(res.msg, {
													icon: 5
												});
											}

											table.reload('LAY-user-manage');
											layer.close(index); //关闭弹层
										}
									});
								});

								submit.trigger('click');
							}
						});
						break;
					case 'getCheckLength':
						var data = checkStatus.data;
						layer.msg('选中了：' + data.length + ' 个');
						break;
					case 'isAll':
						layer.msg(checkStatus.isAll ? '全选' : '未全选')
						break;
				};
			});

			$('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
				var type = $(this).data('type');
				active[type] ? active[type].call(this) : '';
			});
			var laydate = layui.laydate;

			//常规用法
			laydate.render({
				elem: '#test1'
			});

			//国际版
			laydate.render({
				elem: '#test1-1',
				lang: 'en'
			});

			//年选择器
			laydate.render({
				elem: '#test2',
				type: 'year'
			});

			//年月选择器
			laydate.render({
				elem: '#test3',
				type: 'month'
			});

			//时间选择器
			laydate.render({
				elem: '#test4',
				type: 'time'
			});

			//日期时间选择器
			laydate.render({
				elem: '#test5',
				type: 'datetime'
			});

			//日期范围
			laydate.render({
				elem: '#test6',
				range: true
			});

			//年范围
			laydate.render({
				elem: '#test7',
				type: 'year',
				range: true
			});

			//年月范围
			laydate.render({
				elem: '#test8',
				type: 'month',
				range: true
			});

			//时间范围
			laydate.render({
				elem: '#test9',
				type: 'time',
				range: true
			});

			//日期时间范围
			laydate.render({
				elem: '#test10',
				type: 'datetime',
				range: true
			});

			//自定义格式
			laydate.render({
				elem: '#test11',
				format: 'yyyy年MM月dd日'
			});
			laydate.render({
				elem: '#test12',
				format: 'dd/MM/yyyy'
			});
			laydate.render({
				elem: '#test13',
				format: 'yyyyMMdd'
			});
			laydate.render({
				elem: '#test14',
				type: 'time',
				format: 'H点m分'
			});
			laydate.render({
				elem: '#test15',
				type: 'month',
				range: '~',
				format: 'yyyy-MM'
			});
			laydate.render({
				elem: '#test16',
				type: 'datetime',
				range: '到',
				format: 'yyyy年M月d日H时m分s秒'
			});

			//开启公历节日
			laydate.render({
				elem: '#test17',
				calendar: true
			});

			//自定义重要日
			laydate.render({
				elem: '#test18',
				mark: {
					'0-10-14': '生日',
					'0-12-31': '跨年' //每年的日期
					,
					'0-0-10': '工资' //每月某天
					,
					'0-0-15': '月中',
					'2017-8-15': '' //如果为空字符，则默认显示数字+徽章
					,
					'2099-10-14': '呵呵'
				},
				done: function (value, date) {
					if (date.year === 2017 && date.month === 8 && date.date === 15) { //点击2017年8月15日，弹出提示语
						layer.msg('这一天是：中国人民抗日战争胜利72周年');
					}
				}
			});

			//限定可选日期
			var ins22 = laydate.render({
				elem: '#test-limit1',
				min: '2016-10-14',
				max: '2080-10-14',
				ready: function () {
					ins22.hint('日期可选值设定在 <br> 2016-10-14 到 2080-10-14');
				}
			});

			//前后若干天可选，这里以7天为例
			laydate.render({
				elem: '#test-limit2',
				min: -7,
				max: 7
			});

			//限定可选时间
			laydate.render({
				elem: '#test-limit3',
				type: 'time',
				min: '09:30:00',
				max: '17:30:00',
				btns: ['clear', 'confirm']
			});

			//同时绑定多个
			lay('.test-item').each(function () {
				laydate.render({
					elem: this,
					trigger: 'click'
				});
			});

			//初始赋值
			laydate.render({
				elem: '#test19',
				value: '1989-10-14',
				isInitValue: true
			});

			//选中后的回调
			laydate.render({
				elem: '#test20',
				done: function (value, date) {
					layer.alert('你选择的日期是：' + value + '<br>获得的对象是' + JSON.stringify(date));
				}
			});

			//日期切换的回调
			laydate.render({
				elem: '#test21',
				change: function (value, date) {
					layer.msg('你选择的日期是：' + value + '<br><br>获得的对象是' + JSON.stringify(date));
				}
			});
			//不出现底部栏
			laydate.render({
				elem: '#test22',
				showBottom: false
			});

			//只出现确定按钮
			laydate.render({
				elem: '#test23',
				btns: ['confirm']
			});

			//自定义事件
			laydate.render({
				elem: '#test24',
				trigger: 'mousedown'
			});

			//点我触发
			laydate.render({
				elem: '#test25',
				eventElem: '#test25-1',
				trigger: 'click'
			});

			//双击我触发
			lay('#test26-1').on('dblclick', function () {
				laydate.render({
					elem: '#test26',
					show: true,
					closeStop: '#test26-1'
				});
			});

			//日期只读
			laydate.render({
				elem: '#test27',
				trigger: 'click'
			});

			//非input元素
			laydate.render({
				elem: '#test28'
			});

			//墨绿主题
			laydate.render({
				elem: '#test29',
				theme: 'molv'
			});
			//墨绿主题
			laydate.render({
				elem: '#test29two',
				theme: 'molv'
			});

			//自定义颜色
			laydate.render({
				elem: '#test30',
				theme: '#393D49'
			});

			//格子主题
			laydate.render({
				elem: '#test31',
				theme: 'grid'
			});

			//直接嵌套显示
			laydate.render({
				elem: '#test-n1',
				position: 'static'
			});
			laydate.render({
				elem: '#test-n2',
				position: 'static',
				lang: 'en'
			});
			laydate.render({
				elem: '#test-n3',
				type: 'month',
				position: 'static'
			});
			laydate.render({
				elem: '#test-n4',
				type: 'time',
				position: 'static'
			});
		});
	</script>
</body>

</html>